var initTree1 = function() {
	//初始化第一棵树，呈现所有的班级，供选择
	$('#tree_1').jstree({
		'plugins' : [ "wholerow", "checkbox" ],
		'core' : {
			"themes" : {
				"responsive" : false
			},
			'data' : treeData
		},
		"types" : {
			"default" : {
				"icon" : "fa fa-folder icon-state-warning icon-lg"
			},
			"file" : {
				"icon" : "fa fa-file icon-state-warning icon-lg"
			}
		}
	});
	//
	$('#tree_1').bind("select_node.jstree", change1);
	//
	$('#tree_1').bind("deselect_node.jstree", change1);
}
//tree1选中、反选事件
function change1() {
	var nodes = $('#tree_1').jstree().get_selected(true);
	var nodeTexts = [];
	for (var i = 0; i < nodes.length; i++) {
		var ni = nodes[i];
		var pn = $('#tree_1').jstree().get_node(ni.parent);
		if(!pn.state.selected){//如果父级没选中
			nodeTexts.push(ni.text);
		}
	}
	$('#receivers').val(nodeTexts.toString());
}

initTree1();

$('#a_tree_1').click(function(){
	if($(this).hasClass('fa-plus-square-o')){
		$(this).attr('class','fa fa-minus-square-o');
		$('#tree_1').jstree().open_all();
	}else{
		$(this).attr('class','fa fa-plus-square-o');
		$('#tree_1').jstree().close_all();
	}
});

function selectReceivers(){
	$('#popWin').modal().show();
}
